<?php
/**
 * OS CRM SYSTEM - An open source application development framework for PHP 4.3.2 or newer
 *
 * CLASS - SITE ADMIN
 * 
 * @name      siteadmin
 * @package		OS CRM
 * @category  Class
 * @author		CRM SYSTEM Dev Team
 * @copyright	Copyright (c) 2010 - 2012, CRM SYSTEM
 * @since     Version 1.0
 * @filesource
 * @access    public 
 */

// ------------------------------------------------------------------------

class siteadmin extends Controller {
  
  /*common class varibale*/
  var $c 	= 'siteadmin';//current controler
	var $p_c = '';//parent controller
  
  //set db - listing data
	var $e_list_limit 	= '10';
	var $e_list_offset 	= '0';
	var $e_list_order   = 'asc';
	var $e_list_order_by= ''; 
  
  /*message strings*/
  var $valid_success 	= '';
  var $valid_errors 	= '';
  var $valid_notice 	= '';
  
  /**
   * siteadmin  - constructor of the class
   * 
   * @access public
   * @param  NA
   * @return void
   */
	function siteadmin()
	{
		parent::Controller();	
    
    $this->lang->load('common', ADMIN_LANGUAGE);
    $this->load->model('DB_Model', 'db_model');
	}
	
  //-----------------------------------------------------------------
   
  /** 
	 * Index
	 *
	 * @desc NA
	 * @access public/private
	 * @param  NA	 
	 * @return void/mixed
	 */
	function index()
	{
    $data = array();
		$data['cont_title'] 	= 'Admin Login';
		
		/*set crontroller info*/
		$data['c'] 	= $this->c;
		$data['p_c'] 	= $this->p_c;
		    
    $token = random_string();
    /*set form actions*/
    $data['frm_name']   = 'frmadminlogin';
    $data['frm_action'] = site_url( $this->c .'/ajax/check');
    $data['frm_token']  = $token;
    $data['frm_mode']   = 'adminlogin';
    $data['frm_id']      = '';
        
    $this->session->set_userdata('frm_token', $token);
    
    /*set message strings*/
    $data['msg_info']['valid_errors'] = $this->valid_errors;
    $data['msg_info']['valid_notice'] = $this->valid_notice;
    $data['msg_info']['valid_success'] = $this->valid_success;
    
    __admin_display('login', $data);
	}
  
  //-----------------------------------------------------------------
   
  /** 
	 * Dashboard
	 *
	 * @desc admin dashboard
	 * @access public
	 * @param  NA	 
	 * @return void
	 */
	function dashboard()
	{
    if(!__admin_loggedin()){
      redirect(OS_CRM_SITEADMIN);
    }
    $data = array();
		$data['cont_title'] 	= 'Admin Dashboard';
				
		/*set crontroller info*/
		$data['c'] 	= $this->c;
		$data['p_c'] 	= $this->p_c;
		    
    $token = random_string();
    /*set form actions*/
    $data['frm_name']   = 'frmadmindash';
    $data['frm_action'] = site_url( $this->c );
    $data['frm_token']  = $token;
    $data['frm_mode']   = 'admindash';
    $data['frm_id']      = '';
    
    $jor_not_map = $this->db_model->bk_get_jor_not_map();
    $contact_cnt = $this->db_model->bk_get_contact_cnt();
    $order_cnt = $this->db_model->bk_get_order_cnt();
    
    $data['sum_jour'] = $jor_not_map['list']['cnt'];
    $data['sum_contact'] = $contact_cnt['list']['cnt'];
    $data['sum_orders'] = $order_cnt['list']['cnt'];
    
    $this->session->set_userdata('frm_token', $token);
    /*set message strings*/
    $data['msg_info']['valid_errors'] = $this->valid_errors;
    $data['msg_info']['valid_notice'] = $this->valid_notice;
    $data['msg_info']['valid_success'] = $this->valid_success;
    
    __admin_display('dashboard', $data);
	}
  
  /** 
	 * Logout
	 *
	 * @descp NA
	 * @access public
	 * @param  NA	 
	 * @return void
	 */
	function logout()
	{
		$this->session->unset_userdata('adminusr_info');
    $this->session->sess_destroy();
		redirect($this->c);
	}
}

/* End of file siteadmin.php */
/* Location: ./system/application/modules/siteadmin/controllers/siteadmin.php */